import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'LogisticsCard.settings')
django.setup()

from LogisticsCard.models import CardOrder
from django.utils import timezone
import random

def batch_create_orders():
    for i in range(20):
        order = CardOrder.objects.create(
            order_type='buy',
            order_no=f'TEST{timezone.now().strftime("%Y%m%d%H%M%S")}{random.randint(1000,9999)}',
            package='测试套餐',
            card_count=random.randint(1, 10),
            amount=round(random.uniform(10, 100), 2),
            status='pending',
            remark='批量插入测试',
            receiver='张三',
            delivery_phone='13800000000',
            delivery_address='测试地址'
        )
        print(f'创建订单: {order.order_no}')

if __name__ == '__main__':
    batch_create_orders()
